/**
 * @fileOverview
 * @author iNahoo
 * @since 2018/5/4.
 */
"use strict";


import React, {PureComponent, Component} from 'react';
import ReactDOM from 'react-dom';

class A extends Component {
    render() {
        console.log('render - A');
        return <p>a:{this.props.v}</p>
    }
}


class B extends Component {
    render() {
        console.log('render - B');
        return <p>b:{this.props.v}</p>
    }
}


class Main extends Component {
    constructor(props) {
        super(props);
        this.state = {
            a: 1,
            b: 1,
        }
    }

    render() {
        console.log('\nrender - Main');

        return <div>
            <A v={this.state.a}></A>
            <B v={this.state.b}></B>
            <div onClick={() => {
                this.setState(state => ({
                    a: state.a,
                }))
            }}>点我加A</div>
        </div>
    }

}

ReactDOM.render(
    <Main></Main>,
    document.getElementById('app'),
);